package com.security.spring.controller;

import com.security.spring.web.rs.UserDTO;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

/**
 * @author Administrator
 */
@Component
public class BaseController {
    /**
     * 获取user信息
     *
     * @return
     */
    protected UserDTO getUser() {
        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        UserDTO userDTO = (UserDTO) principal;
        return userDTO;
    }
}
